import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { BrowserRouter,Routes,Route, useParams, useSearchParams } from 'react-router-dom';
import Layout from './layout/index'

const root = ReactDOM.createRoot(document.getElementById('root'));



function User(){
  const params=useParams()

  const [searchParams,setParams]=useSearchParams()
  const name=searchParams.get('name')
  console.log(name,'name');


  return (
    <div>
      <h1> {params.id}</h1>
      <button onClick={()=>{setParams({
        name:'kunkun',age:18
      })}}>设置用户参数</button>
     </div>

  )

}
root.render(
  <BrowserRouter>
  <Routes>
    <Route path='/' element={<Layout/>}>
    <Route path='/app' element={<App />}></Route>
    <Route path='/user/:id' element={<User />}></Route>
    </Route>
  
  </Routes>
  </BrowserRouter>
    
  
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
